package com.micro.frog.core.common;


import java.io.Serializable;

/** 统一出参类
 * @author :  ljh
 * @date : 2018/4/3
 **/
public class Result implements Serializable{

    private boolean flag;

    private String code;

    private String msg;

    private Object data;

    public Result() {
        this.flag = false;
    }

    public Result(boolean flag, String code, String msg, Object data) {
        this.flag = flag;
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Result(boolean flag, String msg) {
        this.flag = flag;
        this.msg = msg;
    }

    public Result(boolean flag, String msg, Object data) {
        this.flag = flag;
        this.msg = msg;
        this.data = data;
    }

    public static Result newResult() {
        return new Result();
    }

    public static Result ok(){
        return new Result(true,null);
    }

    public static Result ok(String msg){
        return new Result(true,msg);
    }

    public static Result ok(Object data){
        return new Result(true,null, data);
    }

    public static Result ok(String msg, Object data) {
        return new Result(true, msg, data);
    }

    public static Result fail(){
        return new Result(false,null);
    }

    public static Result fail(String msg){
        return new Result(false,msg);
    }

    public static Result fail(String msg, Object data) {
        return new Result(false, msg, data);
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
